
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using jSLCore.Client.Utility;

namespace jSLCore.Client.Presentation.Common
{
    /// <summary>
    /// SL
    /// </summary>
    public static class SLWPFSelector
    {
        public static ResourceDictionary LoadVisualResource()
        {
            return new ResourceDictionary() { Source = new Uri(@"/jSLCore.Client.Presentation;component/DefaultSLVisualStyle.xaml", UriKind.RelativeOrAbsolute) };
        }

        public static FrameworkElement GetFocusedElement(this Control control)
        {
            return FocusManager.GetFocusedElement() as FrameworkElement;
        }


        public static void ReloadHtmlPage(this ContentContainerBase contentContainerBase)
        {
            System.Windows.Browser.HtmlPage.Window.Navigate
             (new Uri(
                  UIHelper.GetCurrentWebPageAddress()));
        }

        public static string GetDefaultElementPath(this FrameworkElement element)
        {
            if (element is HyperlinkButton) return "Content";
            if (element is Rating) return "Value";
                return null;
        }

        
        
        private const string DirtyHack = "";
        public static Uri CompileResourceString(string relativeUri)
        {
            return new Uri(string.Format(@"/jSLCore.Client.Presentation{0};component/{1}", DirtyHack, relativeUri),
                           UriKind.RelativeOrAbsolute);
        }

        public static bool ShowUIError(FrameworkElement element, string errorText)
        {
            return false;//The code exists in ValidationBinding class for SilverLight
        }
    }
}